package taskqueue

import (
	"sync"
	"github.com/astaxie/beego/logs"
	"cloud_worm/util/uqueue"
)

var wg sync.WaitGroup

var slowQueue *uqueue.SlowQueue
var slowQueueOnce sync.Once

func SlowQueueInst() *uqueue.SlowQueue {
	return slowQueue
}

func init()  {
	slowQueueOnce.Do(func() {
		// slow queue的长度设置为100w的长度
		slowQueue = uqueue.NewSlowQueue(1024 * 100 * 10, 0)
		if slowQueue == nil {
			panic("NewSlowQueue error")
		}

		slowQueue.Run(&wg)
		logs.Info("Starting slow queue.")
	})
}
